package com.koron.common.web.follow.controller;

import com.koron.bean.base.Response;
import com.koron.bean.system.staff.vo.EamUser;
import com.koron.common.core.annocation.CasUser;
import com.koron.common.web.follow.bean.followBean;
import com.koron.common.web.follow.service.followService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@Slf4j
@RestController
@RequestMapping("/follow")
@Api(tags = "关注功能")
public class FollowController {
    @Autowired
    private followService service;

    @PostMapping("/addfollow")
    @ApiOperation(value = "点击关注")
    public Response addfollow(@CasUser @ApiIgnore EamUser user, @RequestBody followBean follow) {
        follow.setAccount(user.getAccount());
        follow.setUsername(user.getName());
        follow.setRent(user.getCurrDs());
//               follow.setRent(ThreadLocalContext.getApp().getId());
        return ADOConnection.runTask(user.getCurrDs(), service, "addfollow", Response.class, follow);
    }

    @PostMapping("/cancelfollow")
    @ApiOperation(value = "取消关注")
    public Response cancelfollow(@CasUser @ApiIgnore EamUser user, @RequestBody followBean follow) {
        follow.setAccount(user.getAccount());
        follow.setUsername(user.getName());
        follow.setRent(user.getCurrDs());
//               follow.setRent(ThreadLocalContext.getApp().getId());
        return ADOConnection.runTask(user.getCurrDs(), service, "cancelfollow", Response.class, follow);
    }

    @PostMapping("/serchfollow")
    @ApiOperation(value = "查询关注列表")
    public Response serchfollow(@CasUser @ApiIgnore EamUser user, @RequestBody followBean follow) {
        follow.setAccount(user.getAccount());
        follow.setUsername(user.getName());
        follow.setRent(user.getCurrDs());
//       follow.setRent(ThreadLocalContext.getApp().getId());
        return ADOConnection.runTask(user.getCurrDs(), service, "serchfollow", Response.class, follow);
    }

    @PostMapping("/getfollow")
    @ApiOperation(value = "判断是否关注")
    public Response getfollow(@CasUser @ApiIgnore EamUser user, @RequestBody followBean follow) {
        follow.setAccount(user.getAccount());
        follow.setUsername(user.getName());
        follow.setRent(user.getCurrDs());
//               follow.setRent(ThreadLocalContext.getApp().getId());
        return ADOConnection.runTask(user.getCurrDs(), service, "getfollow", Response.class, follow);
    }
}
